package leetcode.code1357;

public class Cashier {

	int n, discount;
	int[] products, prices;
	int id;

	public Cashier(int n, int discount, int[] products, int[] prices) {
		this.n = n;
		this.discount = discount;
		this.products = products;
		this.prices = new int[201];
		for (int i = 0; i < prices.length; i++) {
			this.prices[products[i]] = prices[i];
		}
		this.id = 1;
	}

	public double getBill(int[] product, int[] amount) {
		double x = 0d;
		for (int i = 0; i < amount.length; i++) {
			x += 1d * prices[product[i]] * amount[i];
		}
		id %= n;
		if (id == 0) {// 打折
			x -= (1d * this.discount * x) / 100;
		}
		id++;
		return x;
	}

}
